package com.gzu.ltms.entity.table;

import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.table.TableDef;

import java.io.Serial;

/**
 * 配送员月度绩效表 表定义层。
 *
 * @author mm
 * @since 2025-05-06
 */
public class CourierPerformanceTableDef extends TableDef {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 配送员月度绩效表
     */
    public static final CourierPerformanceTableDef COURIER_PERFORMANCE = new CourierPerformanceTableDef();

    /**
     * 绩效id
     */
    public final QueryColumn ID = new QueryColumn(this, "id");

    /**
     * 统计月份
     */
    public final QueryColumn MONTH = new QueryColumn(this, "month");

    /**
     * 客户评分
     */
    public final QueryColumn SCORE = new QueryColumn(this, "score");

    /**
     * 配送员id
     */
    public final QueryColumn COURIER_ID = new QueryColumn(this, "courier_id");

    /**
     * 平均响应时间（分钟）
     */
    public final QueryColumn AVG_RESPONSE_TIME = new QueryColumn(this, "avg_response_time");

    /**
     * 所有字段。
     */
    public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");

    /**
     * 默认字段，不包含逻辑删除或者 large 等字段。
     */
    public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, COURIER_ID, MONTH, AVG_RESPONSE_TIME, SCORE};

    public CourierPerformanceTableDef() {
        super("", "courier_performance");
    }

    private CourierPerformanceTableDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public CourierPerformanceTableDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new CourierPerformanceTableDef("", "courier_performance", alias));
    }

}
